<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList, java.util.List"%>
<%@page pageEncoding="utf-8"%>
<%@page import="java.sql.*, com.liangjie.bbs.*"%>

<%!private void tree(Connection conn, List<Article> articles, int id, int level) {
		String sql = "select * from article where pid = " + id;
		Statement stmt = DB.getStmt(conn);
		ResultSet rs = DB.executeQuerey(stmt, sql);
		try {
			while (rs.next()) {
				Article article = new Article();
				article.initFromJsp(rs);
				article.setLevel(level);
				articles.add(article);

				if (!article.isLeaf()) {
					tree(conn, articles, article.getId(), level + 1);
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DB.close(rs);
			DB.close(stmt);
		}
	}%>

<%
	List<Article> articles = new ArrayList<Article>();
	Connection conn = DB.getConn();
	tree(conn, articles, 0, 0);
	DB.close(conn);
%>

<%
	String adminLogined = (String) session.getAttribute("logined");
	boolean logined = false;
	if (adminLogined != null && adminLogined.equals("true")) {
		logined = true;
	} else {
		logined = false;
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0040)http://cn.club.vmall.com/forumall-1.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>主题列表——树状</title>

<link rel="stylesheet" type="text/css"
	href="./sources/article/style_5_common.css" />
</head>
<body>
	<div id="wp" class="wp">
		<div id="wp" class="wp">
			<div class="boardnav">
				<div id="ct" class="wp cl ct2">
					<div class="mtw">
						<div class="bm bml thd-tags">

							<%
								if (!logined) {
							%>
							<div align="right">
								<a href="./login.jsp">管理员登陆</a>
							</div>
							<%
								}
							%>
							<div class="thdtag-poll mkclearfix">
								<h2>BBS论坛——树状展现</h2>
							</div>
							<div class="thdpp-sub">
								<p>欢迎光临，本页面来自华为花粉俱乐部！</p>

							</div>
						</div>
						<%
							Iterator<Article> it = articles.iterator();
							while (it.hasNext()) {
								Article article = it.next();
								String preString = "";
								for (int i = 0; i < article.getLevel(); i++) {
									preString += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
								}
						%>
						<div id="threadlist" class="tl thd_bmw">
							<div class="bm_c thd_bm">
								<div id="forumnew" style="display:none"></div>
								<form method="post" name="moderate" id="moderate"
									action="http://cn.club.vmall.com/forum.php?mod=topicadmin&action=moderate&fid=0&infloat=yes&nopost=yes">
									<table summary="forum_0" cellspacing="0" cellpadding="0"
										id="threadlisttableid">
										<tbody id="stickthread_4641783">
											<tr>
												<th class="common">
													<div class="avatarbox">
														<img src="./sources/article/bagua.png" alt="头像" />
													</div>
													<div class="thdpp-cont">
														<a href="./article_detail.jsp?id=<%=article.getId()%>"
															style="font-weight: bold;color: #EE1B2E;"
															onclick="atarget(this)" class="s xst"><%=preString + article.getTitle()%></a>
														<img src="./sources/article/pin_3.gif" alt="全局置顶" /> <img
															src="./sources/article/rushreply_s.png" alt="抢楼" /> <span
															id="rushtimer_4641783"> 【还有 <span
															id="rushtimer_body_4641783">3天7小时33分39秒</span> 结束 】
														</span> <img src="./sources/article/image_s.gif" alt="attach_img"
															title="图片附件" /> <span class="tps" style="display:none;">&nbsp;...<a
															href="http://cn.club.vmall.com/thread-4641783-2-1.html">2</a><a
															href="http://cn.club.vmall.com/thread-4641783-3-1.html">3</a><a
															href="http://cn.club.vmall.com/thread-4641783-4-1.html">4</a><a
															href="http://cn.club.vmall.com/thread-4641783-5-1.html">5</a><a
															href="http://cn.club.vmall.com/thread-4641783-6-1.html">6</a>..<a
															href="http://cn.club.vmall.com/thread-4641783-1677-1.html">1677</a></span>
														<div class="thd-sinfo">

															<%
																if (logined) {
															%>
															<span class="thd-ico thd-replies"><a
																href="./delete.jsp?id=<%=article.getId()%>
																&isLeaf=<%=article.isLeaf()%>&pId=<%=article.getpId()%>">DEL</a></span>
															<%
																}
															%>
															<em> <a
																href="http://cn.club.vmall.com/space-uid-8157381.html">LiangJie
																	<img src="./sources/article/v.png" />
															</a>
															</em> <em> 于 <span><span title="2015-6-15"><%=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss")
						.format(article.getpDate())%>&nbsp;发表</span></span> 最后回复 <span><span
																	title="2015-6-19 16:24">1&nbsp;秒前</span></span></em>
														</div>
													</div>

												</th>
											</tr>
										</tbody>
									</table>
									<!-- end of table "forum_G[fid]" branch 1/3 -->
								</form>
							</div>
						</div>
						<%
							}
						%>
						<div class="bm pgs cl hbp-pager mkclearfix">
							<span id="fd_page_bottom" />
							<div class="pg">
								<strong>1</strong><a href="">2</a><a href="">3</a><a href="">4</a><a
									href="">5</a><a href="">6</a><a href="">7</a><a href="">8</a><a
									href="">9</a><a href="">10</a><a href="" class="last">...
									793</a> <label> <span title="共 793 页"> / 793 页</span></label> <a
									href="" class="nxt">下一页</a>
							</div>
							<span id="visitedforumstmp" class="mkbtn-blue newpost" /><a
								href="./post.jsp？from=tree"><font color="white">发布新帖</font></a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="ft" class="wp cl">
		<div id="flk" class="wp mk-box">
			<p>
				Copyright © 2011-2013 华为软件技术有限公司 版权所有 保留一切权利 <a
					href="http://cn.club.vmall.com/huawei/static/html/company.html"
					target="_blank">苏网文[2012]0401-019号</a>
			</p>
		</div>
	</div>
</body>
</html>
